package cn.Mmovie.servlet;

import cn.Mmovie.bean.Cinema;
import cn.Mmovie.service.CinemaService;
import cn.Mmovie.service.impl.CinemaServiceImpl;
import cn.Mmovie.util.PageUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "CinemaListServlet", value = "/admin/cinema_list")
public class CinemaListServlet extends HttpServlet {
    private CinemaService cinemaService=new CinemaServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Integer pageNo=1;
        Integer pageSize=10;
        if (request.getParameter("pageNo")!=null&&request.getParameter("pageNo")!=""){
            pageNo=Integer.parseInt(request.getParameter("pageNo"));
        }
        if (request.getParameter("pageSize")!=null&&request.getParameter("pageSize")!=""){
            pageSize=Integer.parseInt(request.getParameter("pageSize"));
        }
        PageUtil<Cinema> page=cinemaService.page(pageNo,pageSize);
        request.setAttribute("page",page);
        request.getRequestDispatcher("/WEB-INF/page/main/cinema_list.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
